package com.huike.web.controller.contract;

import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.contract.domain.dto.TransferPageQueryDTO;
import com.huike.contract.domain.vo.TransferVo;
import com.huike.contract.result.TransferAssignmentData;
import com.huike.contract.service.TransferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 转派相关请求
 * @Date 2023-10-10
 */
@RequestMapping("/transfer")
@RestController
@Slf4j
@Api("转派相关接口")
@AllArgsConstructor
public class TransferController {

    private TransferService transferService;

    /**
     * 获取转派列表
     *
     * @param transferPageQueryDTO
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("获取转派列表")
    public TableDataInfo<List<TransferVo>> page(TransferPageQueryDTO transferPageQueryDTO) {
        log.info("执行获取转派列表:{}", transferPageQueryDTO);
        return transferService.pageTransfer(transferPageQueryDTO);
    }

    @PutMapping("/assignment/{type}/{userId}/{transferUserId}")
    @ApiOperation("转派处理")
    public AjaxResult<TransferAssignmentData> transfer(
            @PathVariable String type ,
            @PathVariable Integer userId,
            @PathVariable Integer transferUserId) {
        log.info("执行转派处理:{},{},{}", transferUserId, userId, type);
        TransferAssignmentData transferAssignmentData = transferService.transfer(transferUserId, userId, type);
        return AjaxResult.success(transferAssignmentData);
    }
}
